<!DOCTYPE html>
<html>
<head>
    <title>节点邮件设置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" id="bpm_theme" type="text/css" href="../../easyui/newtheme/bule/devclient.css">
    <script type="text/javascript" src="../../jscode/lang/zh_CN.js"></script>
    <script type="text/javascript" src="../../easyui/jquery.min.js"></script>
    <script type="text/javascript" src="../../easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../jscode/sharefunction.js"></script>
    <script type="text/javascript" src="../../jscode/json.js"></script>
    <script type="text/javascript" src="../../jscode/viewgrid.js"></script>
    <script type="text/javascript" src="../../easyui/locale/easyui-lang-zh_CN.js"></script>
    <script>

        var CONFIG = [];
        $.ajax({
            url: "../config/config.json",
            //同步请求
            async: false,
            type: 'GET',
            success: function (data) {
                CONFIG = data;
            }
        });

        var getMailConfUrl = CONFIG.url.getFlowChartMailConfigByNodeType;
        getMailConfUrl = getMailConfUrl.replace("{processid}", GetUrlArg("Processid")).replace("{nodeid}", GetUrlArg("Nodeid"));

        $(function () {
            $('#dg').datagrid({
                method: 'GET',
                url: getMailConfUrl,
            });
            // $('#dg').datagrid('load');
        })

        function formatlink(v, r) {
            return "<a href='' onclick=\"RowDblClick(0,'" + r.WF_OrUnid + "','" + r.UIType + "');return false;\" >" + v + "</a>";
        }

        function GroupFormat(value, rows) {
            return value + ' - ' + rows.length + ' 项';
        }

        $(window).resize(function () {
            $('#dg').datagrid('resize', {
                width: function () {
                    return document.body.clientWidth;
                },
                height: function () {
                    return document.body.clientHeight;
                }
            });
        });

        function RowDblClick(rowIndex, rowData) {
            var docunid;
            if (typeof rowData == "string") {
                docunid = rowData;
            } else {
                docunid = rowData.WF_OrUnid;
            }
            if (docunid == undefined || docunid == "") {
                alert("No wf_orunid fields in datasource!");
                return;
            }
            //var url = "form?wf_num=" + FormNum + "&wf_action=edit&wf_docunid=" + docunid + "&Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid");
            var url = "../html/AddEmailForm.html?wf_action=edit&wf_docunid=" + docunid + "&Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid");
            location.href = url;
        }

        function RowClick(index) {
            $("#dg").datagrid('unselectAll');
            $("#dg").datagrid('selectRow', index);
        }

        function NewDoc() {
            //var url = "form?wf_num=" + FormNum + "&Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid");
            var url = "../html/AddEmailForm.html?Processid=" + GetUrlArg("Processid") + "&Nodeid=" + GetUrlArg("Nodeid");
            location.href = url;
        }

        function DeleteDoc() {
            var rows = $('#dg').datagrid('getSelections');
            if (rows.length > 0) {
                var ids = []; //ID对象
                for (var i = 0; i < rows.length; i++) {
                    ids.push(rows[i]['WF_OrUnid']);
                }
                var IDs = ids.join(','); //将ids对象用‘，’连接成字符串
            }else {
                alert("请勾选要删除的记录！");
                return;
            }
            $.post(CONFIG.url.deleteFlowChartMailConfigByNodeType + "?docUnidList=" + IDs, function (data) {
                alert(data.ok);
                $('#dg').datagrid('load');
            });
        }

        function CopyDoc() {
            GridCopyDoc($('#dg'));
        }

        function btnClick(btnid) {
            GridBtnClick($('#dg'), btnid);
        }

        function serializeForm() {
            return "";
        }
    </script>
</head>
<body style="margin:0px;">
<div class="toptoolbar" id="toptoolbar">
    |
    <a href="#" id="btnNew" class="easyui-linkbutton" plain="true" data-options="iconCls:'icon-add'"
       onclick="NewDoc();return false;">新增设置</a>|
    <a href="#" id="btnDel" class="easyui-linkbutton" plain="true" data-options="iconCls:'icon-remove'"
       onclick="DeleteDoc();return false;">删除设置</a>|
</div>
<table id="dg" class="easyui-datagrid"
       data-options="toolbar:toptoolbar,fit:true,autoRowHeight:false,remoteSort:true,border:false,rownumbers: true,pagination:true,fitColumns:true,singleSelect:false,multiSort:true,onDblClickRow:RowDblClick,onClickRow:RowClick,pageSize:25,pageList:[25,30,45,60,100,200],url:'r?wf_num=D_S002_J009&amp;wf_gridnum=V_S002_G006&amp;Processid=c48c400f0c350040c00b25d020dd0b6e816d&amp;Nodeid=T00001&amp;rdm='+Math.random()">
    <thead>
    <tr>
        <th data-options="checkbox:true"></th>
        <th data-options="field:'icon',width:25,align:'center',formatter:function(v,r){return '&lt;img src=../../images/icons/mail.gif &gt;';}"></th>
        <th data-options="field:'Actionid',width:60,sortable:true">对应操作</th>
        <th data-options="field:'MailTitle',width:160,sortable:true,formatter:formatlink">邮件标题</th>
        <th data-options="field:'SendTo',width:100,sortable:true">主送</th>
        <th data-options="field:'CopyTo',width:100,sortable:true">抄送</th>
    </tr>
    </thead>
</table>
<div id="win"></div>
</body>
</html>